package cn.iocoder.yudao.module.system.controller.admin.mini.goodInfo.dis.dal.mysql.disgoods;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.mini.goodInfo.dis.controller.admin.disgoods.vo.DisGoodsExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.goodInfo.dis.controller.admin.disgoods.vo.DisGoodsPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.goodInfo.dis.dal.dataobject.disgoods.DisGoodsDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 折扣商品 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface DisGoodsMapper extends BaseMapperX<DisGoodsDO> {

    default PageResult<DisGoodsDO> selectPage(DisGoodsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DisGoodsDO>()
                .betweenIfPresent(DisGoodsDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DisGoodsDO::getGoodsId, reqVO.getGoodsId())
                .eqIfPresent(DisGoodsDO::getGoodsInfo, reqVO.getGoodsInfo())
                .likeIfPresent(DisGoodsDO::getGoodsName, reqVO.getGoodsName())
                .betweenIfPresent(DisGoodsDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(DisGoodsDO::getEntTime, reqVO.getEntTime())
                .eqIfPresent(DisGoodsDO::getSoldNum, reqVO.getSoldNum())
                .eqIfPresent(DisGoodsDO::getStatus, reqVO.getStatus())
                .orderByDesc(DisGoodsDO::getId));
    }

    default List<DisGoodsDO> selectList(DisGoodsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DisGoodsDO>()
                .betweenIfPresent(DisGoodsDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DisGoodsDO::getGoodsId, reqVO.getGoodsId())
                .eqIfPresent(DisGoodsDO::getGoodsInfo, reqVO.getGoodsInfo())
                .likeIfPresent(DisGoodsDO::getGoodsName, reqVO.getGoodsName())
                .betweenIfPresent(DisGoodsDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(DisGoodsDO::getEntTime, reqVO.getEntTime())
                .eqIfPresent(DisGoodsDO::getSoldNum, reqVO.getSoldNum())
                .eqIfPresent(DisGoodsDO::getStatus, reqVO.getStatus())
                .orderByDesc(DisGoodsDO::getId));
    }

}
